<?php
declare (strict_types=1);

namespace Plugin\Message\Model;

use Mine\MineModel;

class MessageRead extends MineModel
{
    /**
     * The table associated with the model.
     *
     * @var string|null
     */
    protected ?string $table = 'rd_message_read';
    
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = [
        'id', 'message_id', 'user_id', 'status', 'read_time', 'type', 'created_at', 'updated_at'
    ];
    
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = [
        'id' => 'integer',
        'message_id' => 'integer',
        'user_id' => 'integer',
        'status' => 'integer',
        'type' => 'integer',
        'read_time' => 'datetime',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
    ];
    
    /**
     * 消息关联
     */
    public function message(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(Message::class, 'id', 'message_id');
    }
}